define(function () {    
    var ec=require('echarts');
    require('echarts/chart/wordCloud'); 
    
  
   
    var myChart = ec.init(document.getElementById('zifuCloud'));
    
function createRandomItemStyle() {
    return {
        normal: {
            color: 'rgb(' + [
                Math.round(Math.random() * 160),
                Math.round(Math.random() * 160),
                Math.round(Math.random() * 160)
            ].join(',') + ')'
        }
    };
}

var option = {
    tooltip: {
        show: true
    },
    series: [{
        name: '',
        type: 'wordCloud',
        size: ['50%', '50%'],
        textRotation : [0, 45, 90, -45],
        textPadding: 0,
        autoSize: {
            enable: true,
            minSize: 14
        },
        data: [
            {
                name: "aaaaaaaa",
                value: 53,
                itemStyle: {
                    normal: {
                        color: 'red'
                    }
                }
            },
            {
                name: "Macys",
                value: 48,
                itemStyle: createRandomItemStyle()
            }          
        ]
    }]
};

    /**
     * 根据指标显示日数据
     * @param index
     */
    function show(){
        var city_zifuyun_option = $('#city_zifuyun_option').val();
        var cate_zifuyun_option = $('#cate_zifuyun_option').val();
        var beginDate = $('#beginDate_zifuyun').val();

        myChart.showLoading({
            text: '正在努力的读取数据中...'
        });
        $.ajax({
            url: '/dashboard/resume/ajax/getResumeZifuyun',
            type: 'post',
            async: true,
            data:{"city_option":city_option,"cate_option":cate_option,"beginDate":beginDate},
	        dataType: 'json',
            success: function(data, textStatus) {
            	
            	var series_local = [];
                $.each(data.word,function(i, src){
                	series_local[i] = {
                    	name: src,                     
                        'value': data.word[src], 
		                itemStyle: createRandomItemStyle()
                     };
        
                });

                //数据
            option.series.data = series_local;
            
            myChart.setOption(option,true);

            myChart.hideLoading();
            	
            },
            error : function() {
                myChart.hideLoading();
            }
        });
    }

    //时间选择事件
    $('#beginDate_zifuyun').datepicker(datepicker_op);

    var EC={
        echart:myChart,
        resize:function(){myChart.resize();},
        'show':show
    };

    //绑定刷新
    $("#refresh_zifuyun_btn").click(function(){
        EC.show();
    });
    EC.show();
    return EC;
});